package com.lin.blog.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.beans.Transient;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author lin
 * @since 2020-03-08
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="Article对象", description="")
public class Article implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     *   https://blog.csdn.net/qq_28483499/article/details/101317487
     *    使用Mybayis-plus ID_WORKER 生成主键需要注意的事项
     */
    @ApiModelProperty(value = "文章ID")
    @TableId(value = "id", type = IdType.ID_WORKER)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "用户ID")
    @NotNull(message = "用户ID不能为空")
    private Long userId;

    @NotEmpty(message = "文章标题不能为空")
    @ApiModelProperty(value = "文章标题")
    private String title;

    @NotEmpty(message = "文章摘要不能为空")
    @ApiModelProperty(value = "摘要")
    private String summary;

    @NotEmpty(message = "展示图片链接不能为空")
    @ApiModelProperty(value = "展示图片链接")
    private String imgUrl;

    @NotEmpty(message = "文章内容不能为空")
    @ApiModelProperty(value = "文章内容")
    private String content;


    @NotNull(message = "必须指定分类ID")
    @ApiModelProperty(value = "分类ID_唯一")
    private Long categoryId;


    @TableField(exist = false)
    @NotEmpty(message = "必须指定分类标签")
    @ApiModelProperty(value = "标签名_多个 ['数据库',‘JAVA’ ]")
    private List<Long> tagsList;

    @NotEmpty(message = "原作者不能为空")
    @ApiModelProperty(value = "原文作者")
    private String originalAuthor;

    @NotEmpty(message = "作者不能为空")
    @ApiModelProperty(value = "作者")
    private String author;

    @ApiModelProperty(value = "文章等级 数字越高,等级越高")
    private Integer level;

    @ApiModelProperty(value = "是否公开 0 不公开 1 公开")
    private Integer status;

    @ApiModelProperty(value = "点赞数")
    private Integer likes;

    @ApiModelProperty(value = "浏览次数")
    private Integer look;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;


}
